package com.siblings.loan.ui.loan.adapter

import androidx.recyclerview.widget.RecyclerView
import com.lib.base.utils.ImageUtil
import com.siblings.lib_baseadapter.SIBRecyclerViewAdapter
import com.siblings.lib_baseadapter.SIBViewHolderHelper
import com.siblings.loan.R
import org.json.JSONObject

/**
 * Siblings
 * @Author wwdeng
 * @CreateTime: 2024/7/16 14:42
 * @Annotation：贷款 推荐APP适配器
 */
class SibLoanAppsAdapter(recyclerView: RecyclerView?) : SIBRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.item_loan_recommended) {
    override fun setItemChildListener(helper: SIBViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.itemLayout) //点击Item
        helper.setItemChildClickListener(R.id.installLayout) //点击安装
    }

    override fun fillData(helper: SIBViewHolderHelper, position: Int, model: JSONObject) {
        helper.setText(R.id.textAppName,model.optString("appName","xxx"))
        helper.setText(R.id.textAmount,model.optString("appLoanAmount","0"))
        helper.setText(R.id.textScore,model.optString("star","0"))
        helper.setText(R.id.textDownloadCount,model.optString("download","0"))
        val imgLogo = helper.getImageView(R.id.imgLogo)
        ImageUtil.instance!!.loadImageUrl(mContext,imgLogo,model.optString("appLogo"), com.lib.base.R.mipmap.icon_holder)
    }
}